package com.example.firstspringboot.service;

import com.example.firstspringboot.bean.User;
import com.example.firstspringboot.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserService implements IUserService {
    @Autowired
    private UserMapper userMapper;
    @Override
    public User getUserById(Long id) {
        return userMapper.getOne(id);
    }
    @Override
    public List<User> getUsers() {
        return userMapper.getAll();
    }
    @Override
    public List<User> getUsersWithoutId() {
        return userMapper.getAllWithoutId();
    }
    @Override
    public void addUser(User user) {
        userMapper.insert(user);
    }
    @Override
    public User updateUser(User user) {
        userMapper.update(user);
        return user;
    }
    @Override
    public void deleteUserById(Long id) {
        userMapper.delete(id);
    }
}